package com.fishbone.core.boot;

import com.fishbone.core.boot.listener.FishBoneBootstrapListener;
import com.fishbone.core.boot.listener.FishBoneStartingListener;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.ConfigurableApplicationContext;

/**
 * 核心启动类
 *
 * @ClassName FishBoneSpringApplication
 * @Author huyaxi
 * @DATE 2020/4/23 9:34
 */
public class FishBoneSpringApplication {


    public static ConfigurableApplicationContext run(Class<?> source, String... args) {
        return builder(source).run(args);
    }


    /**
     * 获取 SpringApplicationBuilder
     * @param source
     * @return
     */
    public static SpringApplicationBuilder builder(Class<?> source) {
        return new SpringApplicationBuilder(source)
                .initializers(new FishBoneApplicationContextInitializer())
                .listeners(new FishBoneStartingListener(),new FishBoneBootstrapListener())
                .banner(new FishBoneBanner());
    }

}
